package com.haina.shop.controller.index;

import com.haina.shop.context.BaseContext;
import com.haina.shop.result.ServiceResult;
import com.haina.shop.service.UserCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController

public class CollectionController {

    @Autowired
    private UserCollectionService userCollectionService;

    @GetMapping("/p/user/collection/isCollection")
    public ServiceResult isCollection(@RequestParam("prodId") Long prodId){





        int collection = userCollectionService.collection(prodId);
        if (collection >0){
            return ServiceResult.success(true);
        }else {
            return ServiceResult.success(false);
        }

    }
    @PostMapping("/p/user/collection/addOrCancel")
    public ServiceResult addOrCancel(@RequestBody  Long prodId){
        userCollectionService.addOrCancel(prodId);
        return ServiceResult.success();
    }
}
